package com.ysccc.shares.entity;

import java.util.Date;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.ForeignKey;
import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;

import com.google.common.collect.Lists;
import com.ysccc.spring.boot.starter.sqldb.entity.DefaultStategyEntity;

import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 
 * 
 * @author gaofeng
 *
 * @date 2019年4月7日
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Entity
@Table(name = "shares_sale_alert")
public class SharesSaleAlert extends DefaultStategyEntity {

	private static final long serialVersionUID = 1L;

	/** 报警提醒的日期 */
	private Date day;
	
	/** 状态，true：报警，false：关闭 */
	private Boolean status;

	@ManyToMany
	@JoinTable(name = "shares_om_alert_shares"
		, joinColumns = @JoinColumn(name = "alert_id", foreignKey = @ForeignKey(name = "fk_shares_om_alert_shares1"))
		, inverseJoinColumns = @JoinColumn(name = "shares_id", foreignKey = @ForeignKey(name = "fk_shares_om_alert_shares2"))
		, indexes = @Index(columnList = "alert_id, shares_id", name = "i_shares_om_alert_shares", unique = true)
	)
	@Fetch(FetchMode.JOIN)
	@LazyToOne(LazyToOneOption.FALSE)
	private List<Shares> shareses = Lists.newArrayList();
}
